Skip to content

fix: Improve usage reporting#18

Merged
jsonbailey merged 11 commits intomainfrom
devin/AIC-1636-1771538971-improve-usage-reporting
Feb 25, 2026
Merged

fix: Improve usage reporting#18
jsonbailey merged 11 commits intomainfrom
devin/AIC-1636-1771538971-improve-usage-reporting

Conversation

@jsonbailey
Copy link
Contributor

@jsonbailey jsonbailey commented Feb 19, 2026

Requirements

  • I have added test coverage for new or changed functionality
  • I have followed the repository's pull request submission guidelines
  • I have validated my changes against all supported platform versions

Related issues

Describe the solution you've provided

Aligns the Ruby AI SDK's usage tracking with the updated spec from sdk-specs PRs #132, #134, and #135. Four categories of changes:

  1. Renamed usage tracking event key from $ld:ai:config:function:single to $ld:ai:usage:completion-config, matching the new unified $ld:ai:usage:* namespace. (This SDK only has the single completion config method — no judge, agent, or createChat methods — so only one key needed updating.)

  2. Added SDK info tracking on initialization ($ld:ai:sdk:info). When Client is constructed, it fires a single tracking event with SDK name, version, and language using an anonymous context with kind ld_ai and key ld-internal-tracking. SDK identity constants are kept in a dedicated sdk_info.rb module (similar to sdkInfo.ts in JS and sdk_info.py in Python).

  3. Renamed config to completion_config to align with the updated spec method naming. The old config method is preserved as a deprecated proxy that emits a warning and delegates to completion_config.

  4. Split config evaluation into public + private methods to track usage only once per entry point call (matching the pattern from js-core PR #1108). The public completion_config tracks usage and delegates to private _completion_config, which performs the actual evaluation without tracking. This ensures future wrapper methods (e.g. create_chat) can call _completion_config directly to avoid double-counting usage events.

Human review checklist

  • Verify event key string $ld:ai:sdk:info uses colons (not dashes) per sdk-specs PR #135
  • Verify event key string $ld:ai:usage:completion-config exactly matches the spec
  • Verify the anonymous context uses kind ld_ai (underscore) with key ld-internal-tracking per sdk-specs PRs #134/#135
  • Confirm that INIT_TRACK_CONTEXT being created at module load time (outside class Client) is acceptable — it calls LDContext.create when the module is first loaded
  • Confirm the deprecation approach for config (emitting warn on every call) is acceptable for existing consumers
  • Verify completion_config_completion_config delegation is correct and that the deprecated configcompletion_config chain results in exactly one usage track event
  • Confirm private placement only affects _completion_config and does not accidentally make config or completion_config private

Additional context

Co-Authored-By: jbailey@launchdarkly.com <accounts@sidewaysgravity.com>
@devin-ai-integration
Copy link

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

Copy link

@devin-ai-integration devin-ai-integration bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 4 additional findings.

Open in Devin Review

devin-ai-integration bot and others added 2 commits February 23, 2026 22:01
…to ld_ai per sdk-specs #135

Co-Authored-By: jbailey@launchdarkly.com <accounts@sidewaysgravity.com>
devin-ai-integration bot and others added 2 commits February 23, 2026 22:05
Co-Authored-By: jbailey@launchdarkly.com <accounts@sidewaysgravity.com>
…rack usage only once

Co-Authored-By: jbailey@launchdarkly.com <accounts@sidewaysgravity.com>
@jsonbailey jsonbailey marked this pull request as ready for review February 25, 2026 21:16
@jsonbailey jsonbailey requested a review from a team as a code owner February 25, 2026 21:16
@jsonbailey jsonbailey merged commit 9f7ec17 into main Feb 25, 2026
8 checks passed
@jsonbailey jsonbailey deleted the devin/AIC-1636-1771538971-improve-usage-reporting branch February 25, 2026 22:09
jsonbailey added a commit that referenced this pull request Feb 25, 2026
🤖 I have created a release *beep* *boop*
---


##
[0.2.2](0.2.1...0.2.2)
(2026-02-25)


### Bug Fixes

* Improve usage reporting
([#18](#18))
([9f7ec17](9f7ec17))
* Remove bundler version constraint from gemspec
([#20](#20))
([ef18f32](ef18f32))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Jason Bailey <jbailey@launchdarkly.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants